import interceptor from './interceptor';

// 行政区查询
const ADMIN_URL = '/webapi/2.0/region/children';
// 过滤条件查询
const SEARCH_URL = '/webapi/2.0/search/list/page';
// 要素详情查询
const QUERY_FEATURE_URL = '/webapi/2.0/feature/detail';
// 图层树查询
const QUERY_LAYER_TREE_URL = '/webapi/2.0/layer/tree';
// 图层字段对照表查询
const QUERY_LAYER_FIELDS_MAP = '/webapi/2.0/layer/dictionary';
// 统计查询
const QUERY_STATISTICS_URL = '/webapi/2.0/region/statistic';
// 图层要素列表查询
const QUERY_LAYER_LIST_URL = '/webapi/2.0/feature/list/page';
// 图层空间geojson数据查询
const QUERY_LAYER_JSON_URL = '/webapi/2.0/feature/list';
// 要素保存
const FEATURE_SEAVE_URL = '/webapi/2.0/feature/modify';
// 要素添加
const FEATURE_ADD_URL = '/webapi/2.0/feature/add';
// 要素删除
const FEATURE_DELETE_URL = '/webapi/2.0/feature/delete';
// 删除图片
const IMAGE_DELETE_URL = '/webapi/authority/deleteImage';

export default {
    // 行政区查询
    queryAdmin(params) {
        const promise = interceptor.get(ADMIN_URL, {
            params,
        });
        return promise;
    },
    // 过滤条件查询
    queryAll(params) {
        const promise = interceptor.get(SEARCH_URL, {
            params,
        });
        return promise;
    },
    // 要素详情查询
    queryFeatureInfo(params) {
        const promise = interceptor.get(QUERY_FEATURE_URL, {
            params,
        });
        return promise;
    },
    // 图层树查询
    queryLayerTree() {
        const promise = interceptor.get(QUERY_LAYER_TREE_URL);
        return promise;
    },
    // 图层字段对照表查询
    queryLayerFields(){
        const promise = interceptor.get(QUERY_LAYER_FIELDS_MAP);
        return promise;
    },
    // 图层统计查询
    queryStatistics(params) {
        const promise = interceptor.get(QUERY_STATISTICS_URL, {
            params,
        });
        return promise;
    },
    // 图层列表查询
    queryLayerList(data) {
        const promise = interceptor.post(QUERY_LAYER_LIST_URL, data);
        return promise;
    },
    // 图层json数据查询
    queryLayerJson(data) {
        const promise = interceptor.post(QUERY_LAYER_JSON_URL, data);
        return promise;
    },
    saveFeature(data) {
        const promise = interceptor.post(FEATURE_SEAVE_URL, data);
        return promise;
    },
    addFeature(data){
        const promise = interceptor.post(FEATURE_ADD_URL, data);
        return promise;
    },
    deleteFeature(params) {
        const promise = interceptor.get(FEATURE_DELETE_URL, {
            params,
        });
        return promise;
    },
    deleteImage(params) {
        const promise = interceptor.delete(IMAGE_DELETE_URL, {
            data:params,
        });
        return promise;
    },
};
